---
- name: Add elasticsearch-key
  apt_key:
    url: https://artifacts.elastic.co/GPG-KEY-elasticsearch
    state: present
- name: Add stable repository
  apt_repository:
    repo: deb https://artifacts.elastic.co/packages/7.x/apt stable main
    state: present
    update-cache: true
- name: Install apt-transport-https
  apt: 
    name: apt-transport-https
    state: present
- name: Install elasticsearch via apt
  apt:
    name: elasticsearch
    state: latest
    update-cache: true
- name: Starting elasticsearch
  service:
   name: elasticsearch
   state: started